<?php

namespace App\Console\Commands\Shop;

use App\Kuafu\Shop\Model\CameraModel;
use Illuminate\Console\Command;

class InitShopCameraName extends Command
{
    protected $signature = 'initShopCameraName';

    protected $description = '初始化广告位置商屏名称';//- 展示屏 名称修改为 商屏 ps:展示屏 - 1号位 --> 商屏 - 1号位


    public function handle()
    {
        CameraModel::query()
                   ->where("deviceType", CameraModel::DEVICE_TYPE_TV)
                   ->where("isDeleted", 0)
                   ->chunkById(100, function ($cameraModel) {
                       foreach ($cameraModel as $camera) {
                           $name = $camera->name;
                           if (strpos($name, '展示屏') !== false) {
                               $name         = str_replace('展示屏', '商屏', $name);
                               $camera->name = $name;
                               $camera->save();
                           }
                       }
                   });
    }

}
